/// Package import
import 'package:flutter/material.dart';

/// Chart import
import 'package:syncfusion_flutter_charts/charts.dart';

/// Local imports
import '../../../../model/model.dart';
import '../../../../model/sample_view.dart';

/// Render the doughnut series with center elevation.
class DoughnutElevation extends SampleView {
  const DoughnutElevation(Key key) : super(key: key);
  
  @override
  _DoughnutDefaultState createState() => _DoughnutDefaultState();
}

/// State class of doughnut series with center elevation.
class _DoughnutDefaultState extends SampleViewState {
  _DoughnutDefaultState();

  @override
  Widget build(BuildContext context) {
    return getElevationDoughnutChart();
  }

/// Returns the circular charts with center elevation dughnut series.
SfCircularChart getElevationDoughnutChart() {
  return SfCircularChart(
    /// It used to set the annotation on circular chart.
    annotations: <CircularChartAnnotation>[
      CircularChartAnnotation(
          height: '100%',
          width: '100%',
          widget: Container(
              child: PhysicalModel(
                  child: Container(),
                  shape: BoxShape.circle,
                  elevation: 10,
                  shadowColor: Colors.black,
                  color: const Color.fromRGBO(230, 230, 230, 1)))),
      CircularChartAnnotation(
          widget: Container(
              child: const Text('62%',
                  style: TextStyle(
                      color: Color.fromRGBO(0, 0, 0, 0.5), fontSize: 25))))
    ],
    title: ChartTitle(
        text: isCardView ? '' : 'Progress of a task',
        textStyle: const TextStyle(fontSize: 20)),
    series: getElevationDoughnutSeries(isCardView),
  );
}

/// Returns the list of doughnut series which need to be center elevation.
List<DoughnutSeries<ChartSampleData, String>> getElevationDoughnutSeries(
    bool isCardView) {
  final List<ChartSampleData> chartData = <ChartSampleData>[
    ChartSampleData(
        x: 'A', y: 62, pointColor: const Color.fromRGBO(0, 220, 252, 1)),
    ChartSampleData(
        x: 'B', y: 38, pointColor: const Color.fromRGBO(230, 230, 230, 1))
  ];

  return <DoughnutSeries<ChartSampleData, String>>[
    DoughnutSeries<ChartSampleData, String>(
        dataSource: chartData,
        animationDuration: 0,
        xValueMapper: (ChartSampleData data, _) => data.x,
        yValueMapper: (ChartSampleData data, _) => data.y,
        pointColorMapper: (ChartSampleData data, _) => data.pointColor)
  ];
}
}